﻿(function () {
    var app = angular.module('ManageApp', ['ngRoute', 'ui.bootstrap', 'MyControllers', 'MyServices', 'MyFilters', 'MyDirectives', 'MyInterceptors']);

    app.config(['$routeProvider', '$httpProvider', function ($routeProvider, $httpProvider) {
        //路由配置
        var route = $routeProvider;
        route.when('/', { redirectTo: '/examSite/info' });

        // home
        route.when('/manager/list', { templateUrl: 'manager-list' });

        // examSite
        route.when('/examSite/info', { controller: 'siteController', templateUrl: '/Utils/Html/ExamSite-Info' });

        // examPlan
        route.when('/examPlan/list', { controller: 'planController', templateUrl: '/Utils/Html/ExamPlan-List' });
        route.when('/examPlan/detail', { controller: 'planDetailController', templateUrl: '/Utils/Html/ExamPlan-Detail' });

        // examRoom
        route.when('/examRoom/list/:id/:name', { controller: 'roomController', templateUrl: '/Utils/Html/Examroom-List' });
        route.when('/examRoom/setting/:id/:roomName/:planId/:planName', { controller: 'roomSetingController', templateUrl: '/Utils/Html/ExamRoom-SetingRoom' });

        // examMonitor
        route.when('/examMonitor/planList', { controller: 'monitorController', templateUrl: '/Utils/Html/Exammonitor-PlanList' });
        route.when('/examMonitor/detail', { controller: 'monitorDetailController', templateUrl: '/Utils/Html/Exammonitor-Detail' });

        // examReport
        route.when('/examReport/planList', { controller: 'reportPlanController', templateUrl: '/Utils/Html/ExamReport-PlanList' });
        route.when('/examReport/SubjectList', { controller: 'reportSubjectController', templateUrl: '/Utils/Html/ExamReport-SubjectList' });
        route.when('/examReport/tradExamList', { controller: 'reportTradExamController', templateUrl: '/Utils/Html/ExamReport-TradExamList' });
        route.when('/examReport/freeExamList', { controller: 'reportFreeExamController', templateUrl: '/Utils/Html/ExamReport-FreeExamList' });
        route.when('/examReport/freeExamGenerated', { controller: 'reportFreeExamGeneratedController', templateUrl: '/Utils/Html/ExamReport-FreeExamGenerated' });

        // photo
        route.when('/photo/planList', { controller: 'photoPlanController', templateUrl: '/Utils/Html/Photo-PlanList' });
        route.when('/photo/list', { controller: 'photoController', templateUrl: '/Utils/Html/Photo-List' });

        // Randomtestlist
        route.when('/Randomtestlist/Randomtestlist', { controller: 'ExamineeService', templateUrl: '/Utils/Html/Randomtestlist-Randomtestlist' });

        // SignIn
        route.when('/signIn/planList', { controller: 'signInPlanController', templateUrl: '/Utils/Html/SignIn-PlanList' });
        route.when('/signIn/list', { controller: 'signInController', templateUrl: '/Utils/Html/SignIn-List' });

        // process
        route.when('/process/planList', { controller: 'processController', templateUrl: '/Utils/Html/Process-PlanList' });

        // unExpected
        route.when('/unExpected/planList', { controller: 'unExpectedController', templateUrl: '/Utils/Html/UnExpected-PlanList' });
        route.when('/unExpected/control', { controller: 'unExpectedControlController', templateUrl: '/Utils/Html/UnExpected-Control' });

        // examClient
        route.when('/examClient/index', { controller: 'examClientController', templateUrl: '/Utils/Html/ExamClient-index' });

        // route.when('/demo/list', { controller: 'demos', templateUrl: 'demo-list' });
        route.otherwise({ templateUrl: '/Utils/Html/Utils-404' });

        // 注册全局拦截器
        $httpProvider.interceptors.push('myInterceptor');
    }]);
})();

// 表示业务操作结果的枚举
var ResultType = {
    Success: 0,
    NoChanged: 1,
    ParamError: 2,
    QueryNull: 3,
    PurviewLack: 4,
    IllegalOperation: 5,
    Warning: 6,
    Error: 7
};

$(document).ready(function () {
    jQuery.validator.addMethod('isIP', function (value, element) {
        var ipReg = /^((?:(?:25[0-5]|2[0-4]\d|((1\d{2})|([1-9]?\d)))\.){3}(?:25[0-5]|2[0-4]\d|((1\d{2})|([1-9]?\d))))$/;
        return this.optional(element) || ipReg.test(value);
    }, '请正确填写IP地址');

    jQuery.validator.addMethod('isURL', function (value, element) {
        var ipReg = /^(http|ftp|https):\/\/[\w\-_]+([\w\-_]+)+([\w\-\.,@?^=%&amp;:/~\+#]*[\w\-\@?^=%&amp;/~\+#])?$/;
        return true;
    }, '请正确输入网考服务地址');
});